package com.ugoodtech.mdcc.core.repository;

import com.ugoodtech.mdcc.core.domain.AnswerDic;
import com.ugoodtech.mdcc.core.domain.PerformanceReport;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface PerformanceReportRepository extends PagingAndSortingRepository<PerformanceReport, Long>,
        QueryDslPredicateExecutor<PerformanceReport> {

    Page<PerformanceReport> findByEmployeeNameAndYear(String employeeName,Integer year, Pageable pageable);

    List<PerformanceReport> findByEmployeeNameInAndYearIn(List<String> employeeName,List<Integer> year);

    List<PerformanceReport> findByEmployeeName(String employeeName);

    List<PerformanceReport> findByUserName(String userName);

    PerformanceReport findByEmployeeNameAndYearAndStatus(String employeeName, Integer year,Integer operationType);

    @Query("select year from PerformanceReport b  where b.employeeName =:username group by b.year order by b.year desc "  )
    List<Integer> getYearGroup(@Param("username")String username);

    @Query("select year from PerformanceReport b where b.userId = :userId group by b.year")
    List<Integer> getYears(@Param("userId")Long userId);
}
